<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div class="form-group">
        <label for="exampleInputName2">邮箱地址</label> <input type="text"
            class="form-control" id="phone" placeholder="请输入电子邮箱" />
    </div>	
    <input type="button" id="btn" value="发送验证码" onclick="settime(this),send()" /> 
    
    <script type="text/javascript">
    function send(){
        $.ajax({
            url:"sendMessage",
            type:"GET",
            data:"phone="+$("#phone").val(),
            success:function(msg){
                alert("发送邮件了");
            }
        });
    }
    var countdown=10;
    function settime(val) { 
        if (countdown == 0) { 
            val.removeAttribute("disabled"); 
            val.value="免费获取验证码"; 
            countdown = 10;
            return;
        } else { 
            val.setAttribute("disabled", true); 
            val.value="重新发送(" + countdown + ")"; 
            countdown--; 
        } 
        setTimeout(function() { 
            settime(val) },1000)} 
    </script> 

</body>
</html>